package com.design.pattern.structure.decorator.log;

import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;

public class JsonLogger extends LoggerDecorator{
    public JsonLogger(Logger logger) {
        super(logger);
    }

    @Override
    public void info(String s) {
        JSONObject result = newJsonObject();
        result.put("message", s);
        logger.info(result.toString());
    }

    @Override
    public void info(String s, Object o) {
        JSONObject result = newJsonObject();
        result.put("message", s);
        logger.info(result.toString());
    }

    @Override
    public void error(String s) {
        JSONObject result = newJsonObject();
        result.put("message", s);
        logger.info(result.toString());
    }
    private JSONObject newJsonObject(){
        return new JSONObject();
    }
}
